<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.PA;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.PA">
		<cfargument name="PA_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.PA_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new PA();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new PA();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.PA">
		<cfargument name="obj" type="assets.calgrants.com.bo.PA" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.PA_ID")) {
				local.obj.setPA_ID(arguments.PA_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Organization_ID")) {
				local.obj.setOrganization_ID(arguments.Organization_ID); 
			}
			if (IsDefined("arguments.Accepted_By_ID")) {
				local.obj.setAccepted_By_ID(arguments.Accepted_By_ID);
			}
			if (IsDefined("arguments.Program_Year")) {
				local.obj.setProgram_Year(arguments.Program_Year);
			}
			if (IsDefined("arguments.PA")) {
				local.obj.setPA(arguments.PA);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}		
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="PA_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Accepted_By_ID" required="false" default="" />
		<cfargument name="Program_Year" required="false" default="" />
		<cfargument name="PA" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readPA">
			<cfprocparam value="#arguments.PA_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.PA_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organization_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Accepted_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Accepted_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Program_Year#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Program_Year)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.PA#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.PA)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="pa" required="true" type="assets.calgrants.com.bo.PA" />

		<cfstoredproc datasource="#getDatasource()#" procedure="savePA">
			<cfprocparam value="#pa.getPA_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#pa.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#pa.getOrganization_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#pa.getAccepted_By_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#pa.getProgram_Year()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#pa.getPA()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="PA_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyPA">
			<cfprocparam value="#arguments.PA_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

